/**
 * Created by qianzhou on 2017/3/13.
 */
var React = require('react');
var Text = require('../components/Text');
var Icon = require('../components/Icon');
var ajax = require('../tools/ajax');

module.exports = React.createClass({
    getInitialState: function (){
        return {
            theme:"Default",
            slist:[]
        }
    },
    componentDidMount: function () {
        if(this.props.theme) {
            this.setState({theme: this.props.theme});
        }
    },
    action:function(e){
        var action = e.currentTarget.getAttribute("action");
        if(action == "#nearby"){
            this.props.nearby();
        }else{
            location.href = action;
        }
    },
    render: function () {
        var p = this;
        var  slist = this.state.slist.map(function(obj,index){
            return(
                <div key={index} className="home_lr_con fl" style={{float:index?"right":""}} onClick={p.action} action={obj.action}>
                    <div className="fl home_con">
                        <div className="fl home_img_h">
                            <Icon icon={obj.icon} style={{fontSize:"1.2rem",color:"#505050"}}/>
                        </div>
                        <Text title={obj.chinesetitle} name={obj.englishtitle} style={{display:"block",fontWeight:"bold",color:"#333"}}></Text>
                    </div>
                </div>
            )
        });
        return (
            <div className={this.state.theme+"_home_Text"}>
                {slist}
                <div style={{clear:"both"}}></div>
            </div>
        )
    }
});